package QC.MessageBox;

import QC.MessageBox.common.Constants;
import QC.MessageBox.service.HttpService;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Andaren on 2017/4/6.
 * Used for: 部署各个Verticle单元
 */
public class MainVerticle extends AbstractVerticle {

    private static final Logger logger = LoggerFactory.getLogger(MainVerticle.class);

    @Override
    public void start() {
        // verticle配置信息
        logger.info(config().getString("app_ready"));

        // 配置正式环境的环境配置
        configHostAndPortInfo(config());

        DeploymentOptions options = new DeploymentOptions().setConfig(config());
        vertx.deployVerticle(new MSGVerticle(), options);

        logger.info("MSGVerticle部署完成");
    }

    public void configHostAndPortInfo(JsonObject config) {
        // 默认为测试环境
        Constants.WX_INTERFACE_HOST = config.getString("wx_interface_host", "120.25.88.91");
        Constants.WX_INTERFACE_SSLPORT = config.getInteger("wx_interface_sslport", 8584);
        Constants.WX_INTERFACE_HOST_PROXY = config.getString("wx_interface_host_proxy", "http://120.25.88.91:8584");

        HttpService.RC_ISTEST = config.getBoolean("http_server_rc_istest", true);
        HttpService.APPBACK_ISTEST = config.getBoolean("http_server_appback_istest", true);

    }
}
